package com.nmgolden.lanxin.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 基础异常
 */
@EqualsAndHashCode(callSuper = false)
@Data
public class LanxinException extends RuntimeException {

    /**
     * 错误码
     */
    private int code;

    /**
     * 错误消息
     */
    private final String message;

    public LanxinException(int code, String message, Throwable cause) {
        super(message, cause);

        this.code = code;
        this.message = message;
    }

    public LanxinException(int code, String message) {
        this(code, message, null);
    }

    public LanxinException(String message) {
        this(LanxinErrorCode.GENERIC, message);
    }

    public LanxinException(String message, Throwable cause) {
        this(LanxinErrorCode.GENERIC, message, cause);
    }


    @Override
    public String getMessage() {

        return message;
    }

    @Override
    public String toString() {
        return this.getClass() + "{" + ", message='" + getMessage() + '\'' + '}';
    }
}
